var e = require;
var t = module;
var o = exports;
Object.defineProperty(o, "__esModule", {value: !0});
var n = e("BaseModuleUI"),
    a = e("NotifyEventType"),
    i = e("GlobalParams"),
    r = e("AssetsManager"),
    s = e("AudioManager"),
    l = e("CommonHelper"),
    c = e("RoleSoldierInfo"),
    d = e("BigAdNative"),
    h = e("sdkConfig"),
    _ = e("AD"),
    u = e("Toast"),
    p = e("BuyEquipInfo"),
    m = cc._decorator,
    f = m.ccclass,
    g = m.property,
    v = (function (e) {
        function t() {
            var t = (null !== e && e.apply(this, arguments)) || this;
            return (
                (t.revive_time_label = null),
                (t.hero_card_list = []),
                (t.revive_num_label = null),
                (t.hero_view_node = null),
                (t.big_native_node = null),
                t
            );
        }
        return (
            __extends(t, e),
            (t.prototype.initView = function () {
                var e = this;
                h.default.platform == h.EPlatform.TikTok &&
                    (_.default.getInstance().showBanner(), _.default.getInstance().PauseRecorder()),
                    _.default.getInstance().showInter();
                var t = i.GlobalParams.PlayerInfo.value;
                (this.revive_num_label.string = "x" + t.revive),
                    this.showReviveInfo(),
                    (this.hero_view_node.active =
                        h.default.platform != h.EPlatform.No_AD &&
                        !_.default.getInstance().getGameTestVersion() &&
                        !i.GlobalParams.PlayGuideMode),
                    h.default.platform == h.EPlatform.No_AD ||
                    _.default.getInstance().getGameTestVersion() ||
                    i.GlobalParams.PlayGuideMode
                        ? (this.big_native_node.active = !1)
                        : ((this.hero_card_list[1].active = !1),
                          this.big_native_node.getComponent(d.default).showNativeCall(function () {
                              e.hero_card_list[1].active = !0;
                          }),
                          (this.big_native_node.active = !0));
            }),
            (t.prototype.addEvent = function () {
                this.attachEvent(a.default.SEND_GAME_OVER_INFO, this.showGameOver, this);
            }),
            (t.prototype.showGameOver = function () {
                this.node.destroy();
            }),
            (t.prototype.showReviveTime = function (e) {
                this.revive_time_label.string = "" + Math.ceil(e / 10);
            }),
            (t.prototype.showReviveInfo = function () {
                for (var e = 0; e < 2; e++) {
                    var t = i.GlobalParams.ReviveHeroInfo[e],
                        o = c.default.Role_info[t.hero_id];
                    (this.hero_card_list[e].getChildByName("hero_name").getComponent(cc.Label).string = o.C_Name),
                        (this.hero_card_list[e].getChildByName("hero_type").getComponent(cc.Label).string =
                            0 == o.C_type ? "近战英雄" : "远程英雄"),
                        (this.hero_card_list[e].children[0].getComponent(cc.Sprite).spriteFrame = r.default
                            .getInstance()
                            .getHeroCardFrame(o.C_ID)),
                        (this.hero_card_list[e].getChildByName("use_btn_" + e).children[0].children[0].active =
                            t.is_video);
                }
            }),
            (t.prototype.OnClick = function (t) {
                var o = this;
                e.prototype.OnClick.call(this, t);
                var n = t.node.name,
                    a = i.GlobalParams.PlayerInfo.value,
                    r = Number(a.revive);
                switch (n) {
                    case "video_btn":
                        _.default.getInstance().showVideo(function (e) {
                            if ((s.default.playGameBGM(), e == _.ResultEnum.Success))
                                for (var t = 0; t < i.GlobalParams.PlayingRoleDie.length; t++)
                                    i.GlobalParams.PlayingRoleDie[t].role_index == i.GlobalParams.MatchMyIndex &&
                                        ((r += 3),
                                        (a.revive = r),
                                        (i.GlobalParams.PlayingRoleDie[t].cound_down = 1),
                                        (i.GlobalParams.PlayerInfo.value = a));
                        });
                        break;
                    case "revive_btn":
                        if (a.revive > 0) {
                            r--, (a.revive = r), (i.GlobalParams.PlayerInfo.value = a);
                            for (var c = 0; c < i.GlobalParams.PlayingRoleDie.length; c++)
                                i.GlobalParams.PlayingRoleDie[c].role_index == i.GlobalParams.MatchMyIndex &&
                                    (i.GlobalParams.PlayingRoleDie[c].cound_down = 1);
                        } else u.default.showNewToast("复活币不足");
                        break;
                    case "use_btn_0":
                    case "use_btn_1":
                        var d = Number(l.default.getNameType(n, "use_btn_"));
                        i.GlobalParams.ReviveHeroInfo[d].is_video
                            ? _.default.getInstance().showVideo(function (e) {
                                  if ((s.default.playGameBGM(), e == _.ResultEnum.Success)) {
                                      o.useReviveHero(d);
                                      for (var t = 0; t < i.GlobalParams.PlayingRoleDie.length; t++)
                                          i.GlobalParams.PlayingRoleDie[t].role_index == i.GlobalParams.MatchMyIndex &&
                                              (i.GlobalParams.PlayingRoleDie[t].cound_down = 1);
                                  }
                              })
                            : this.useReviveHero(d);
                }
            }),
            (t.prototype.useReviveHero = function (e) {
                var t = i.GlobalParams.MatchGamePlayer[i.GlobalParams.MatchMyIndex],
                    o = t.role_id,
                    n = i.GlobalParams.ReviveHeroInfo[e];
                (t.role_id = n.hero_id), (n.hero_id = o), (n.is_video = !1), (i.GlobalParams.ReviveHeroInfo[e] = n);
                var r = c.default.Role_info[t.role_id],
                    s = p.default.getPlayerInit();
                (s.attack = r.C_attack + r.C_attack_up * t.level),
                    (s.skill_1 = r.S1_attack + r.S1_attack_up * t.skill_info[0]),
                    (s.skill_2 = r.S2_attack + r.S1_attack_up * t.skill_info[1]),
                    (s.hp = r.C_hp + r.C_hp_up * t.level),
                    (s.move_speed = 20),
                    (s.attack_speed = 1),
                    (s.cool_1 = c.default.Hore_Skill_Info[t.role_id].one_time),
                    (s.cool_2 = c.default.Hore_Skill_Info[t.role_id].two_time),
                    0 == t.dower_info[0]
                        ? (s.attack += t.dower_info[1])
                        : 1 == t.dower_info[0]
                        ? (s.move_speed += t.dower_info[1])
                        : 2 == t.dower_info[0]
                        ? (s.hp += t.dower_info[1])
                        : 3 == t.dower_info[0]
                        ? (s.attack_speed -= t.dower_info[1])
                        : 4 == t.dower_info[0] && ((s.cool_1 -= t.dower_info[1]), (s.cool_2 -= t.dower_info[1])),
                    (i.GlobalParams.GamePlayerInfo[i.GlobalParams.MatchMyIndex] = s),
                    this.emitEvent(a.default.SEND_UPDATE_PLAYER_REVIVE_INFO),
                    this.showReviveInfo();
            }),
            __decorate([g(cc.Label)], t.prototype, "revive_time_label", void 0),
            __decorate([g(cc.Node)], t.prototype, "hero_card_list", void 0),
            __decorate([g(cc.Label)], t.prototype, "revive_num_label", void 0),
            __decorate([g(cc.Node)], t.prototype, "hero_view_node", void 0),
            __decorate([g(cc.Node)], t.prototype, "big_native_node", void 0),
            __decorate([f], t)
        );
    })(n.default);
o.default = v;
